package org.example.traing.persistence;


import org.apache.ibatis.annotations.*;
import org.example.traing.entity.JobDetail;
import org.example.traing.entity.User;
import org.example.traing.entity.UserDetail;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@Mapper
public interface UserMapper {




        @Select("select * from user where uid=#{user.Uid} and password=#{user.Password}")
        public User getUser(@Param("user") User user);


        @Insert("insert into user values (#{Uid},#{Password})")
        public int addUser(User user);

        @Insert("insert into user_detail (uid) values(#{uid})")
        public int addUserDetail(String uid);


        @Update("update user set password=#{password} where uid=#{uid} ")
        public int updateUser(User user);


        @Delete("delete from user where uid=#{uid}")
        public int deleteUser(String uid);

        @Select("select * from user_detail where uid=#{uid}")
        public UserDetail getUserDetail(String uid);


        @Update("UPDATE user_detail SET " +
                "user_name = #{userName}, " +
                "user_age = #{userAge}, " +
                "user_phone = #{userPhone}, " +
                "user_status = #{userStatus}, " +
                "user_sex = #{userSex}, " +
                "user_birth = #{userBirth}, " +
                "user_wechat = #{userWechat}, " +
                "user_email = #{userEmail}, " +
                "user_birthplace = #{userBirthplace}, " +
                "user_message= #{userMessage} "+
                "WHERE uid = #{uid}")
        public int updateUserDetail(UserDetail userDetail);


        @Select("select user_job.job_id,job_name,job_address,job_address_detail,job_phone,job_descrption " +
                "from user_job ,job_detail where " +
                "user_job.job_id=job_detail.job_id " +
                "and user_job.uid=#{uid} " +
                "and status='感兴趣' "
                )
        public List<JobDetail> getTreasureJob(String uid);


        @Insert("insert into user_job values(#{uid},#{jobId},'感兴趣')")
        public int addTreasure(String uid,String jobId);

        @Delete("delete from user_job where uid=#{uid} and job_id=#{jobId} and status='感兴趣' ")
        public int deleteTreasure(String uid,String jobId);


        @Select("select user_job.job_id,job_name,job_address,job_address_detail,job_phone,job_descrption " +
                "from user_job ,job_detail where " +
                "user_job.job_id=job_detail.job_id " +
                "and user_job.uid=#{uid} " +
                "and status='面试' "
        )
        public List<JobDetail> getMeetingJob(String uid);

        @Insert("insert into user_job values(#{uid},#{jobId},'面试')")
        public int addMeeting(String uid,String jobId);

        @Delete("delete from user_job where uid=#{uid} and job_id=#{jobId} and status='面试' ")
        public int deleteMeeting(String uid,String jobId);


        @Select("select user_job.job_id,job_name,job_address,job_address_detail,job_phone,job_descrption " +
                "from user_job ,job_detail where " +
                "user_job.job_id=job_detail.job_id " +
                "and user_job.uid=#{uid} " +
                "and status='已投递' "
        )
        public List<JobDetail> getSendJob(String uid);

        @Insert("insert into user_job values(#{uid},#{jobId},'已投递')")
        public int addSend(String uid,String jobId);

        @Delete("delete from user_job where uid=#{uid} and job_id=#{jobId} and status='已投递' ")
        public int deleteSend(String uid,String jobId);







}
